<?php use_stylesheet('teams.css') ?>
<?php slot('title', sprintf('.:: Pronos ::. Liste des pronostics Phase 1'))
?>
<?php if ($sf_user->isAuthenticated() && !$sf_user->hasCredential('admin')): ?>
<h1>Liste des prochains matchs</h1>
<div id="teams">
<table class="teams">
  <thead>
    <tr>
      <th>Id</th>
      <th>Date</th>
      <th colspan="2">Team1</th>
	  <th colspan="3">Pr&eacute;diction</th>
      <th colspan="2">Team2</th>
    </tr>
  </thead>
  <tbody>
    <?php
	foreach ($matchs_date as $i => $pronos_match) : ?>
<?php		$result = $pronos_match->getP1Result();	
			$pronos = $pronos_match->getPronosForUser($sf_user);
			
			$pts = "";
			$class = "";
			
			if($pronos != "") {
				$standing = $pronos->getStanding();
				if($standing != "") {
					$pts = $standing->getNbPts(); 
					if($standing->getIsGood())
						$class = "good";
					if($standing->getIsPerfect())
						$class = "perfect";
					if(!$standing->getIsGood())
						$class = "wrong";
				}
				$score1 = $pronos->getScore1();
				$score2 = $pronos->getScore2();
			} else {
				$score1 = "";
				$score2 = "";
			}
	?>
    <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
		<td><a href="<?php echo url_for('p1match/show?id='.$pronos_match->getId()) ?>"><?php echo $pronos_match->getId() ?></a></td>
		<td class="position"><?php echo $pronos_match->getFDate('d/m H:i') ?></td>
		<td><img src="/pronos/images/teams/<?php echo strtolower($pronos_match->getTeam1()->getCode()) ?>.gif" /></td>
		<td align="right"><?php echo $pronos_match->getTeam1()->getName() ?></td>
		<td align="right"><?php echo $score1 ?></td>
		<td align="center">&nbsp;-&nbsp;</td>
		<td align="left"><?php echo $score2 ?></td>
		<td align="left"><?php echo $pronos_match->getTeam2()->getName() ?></td>
		<td><img src="/pronos/images/teams/<?php echo strtolower($pronos_match->getTeam2()->getCode()) ?>.gif" /></td>
		<td class="<?php echo $class ?>"><?php echo $pts ?></td>
    </tr>
    <?php endforeach; ?>
	<tr><td><?php echo link_to('edit', 'p1pronos/edit') ?></td></tr>
  </tbody>
</table>
</form>
</div>
<br/>
<?php endif ?>
<?php if ($sf_user->isAuthenticated() && $sf_user->hasCredential('admin')): ?>
<h1>Liste des pronostics Phase 1</h1>
<div id="teams">
<table class="teams">
  <thead>
    <tr>
      <th>Id</th>
      <th>User</th>
	  <th colspan="2">Team 1</th>
	  <th colspan="3">Score</th>
      <th colspan="2">Team 2</th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($pronos_p1_pronoss as $i => $pronos_p1_pronos): ?>
		
    <tr class="<?php echo fmod($i, 2) ? 'even' : 'odd' ?>">
      <td align="center"><a href="<?php echo url_for('p1pronos/show?id='.$pronos_p1_pronos->getId()) ?>"><?php echo $pronos_p1_pronos->getId() ?></a></td>
	  <td align="center"><?php echo $pronos_p1_pronos->getUser()->getUsername() ?></td>
	  <?php 
		$team1 = $pronos_p1_pronos->getPronosP1Match()->getTeam1();
		$team2 = $pronos_p1_pronos->getPronosP1Match()->getTeam2();
	  ?>
	  <td align="right"><img src="/pronos/images/teams/<?php echo strtolower($team1->getCode()) ?>.gif" /></td>
      <td align="center"><?php echo $team1->getName() ?></td>
	  <td align="center"><?php echo $pronos_p1_pronos->getScore1() ?></td>
	  <td align="center">&nbsp;-&nbsp;</td>
      <td align="center"><?php echo $pronos_p1_pronos->getScore2() ?></td>
	  <td align="center"><?php echo $team2->getName() ?></td>
	  <td align="left"><img src="/pronos/images/teams/<?php echo strtolower($team2->getCode()) ?>.gif" /></td>
		<?php 
		$class2 = "";
		$pts2 = "";
		$standing = $pronos_p1_pronos->getStanding();
		if($standing != "") {
			$pts2 = $standing->getNbPts(); 
			if($standing->getIsGood())
				$class2 = "good";
			if($standing->getIsPerfect())
				$class2 = "perfect";
			if(!$standing->getIsGood())
				$class2 = "wrong";
		}
		?>
	  <td class="<?php echo $class2 ?>" width="17" ><?php echo $pts2 ?></td>
    </tr>
    <?php endforeach; ?>
  </tbody>
</table>
</div>
<?php endif ?>

